Documentation_Frappe

What actually is Frappe?

Frappe is a full-stack, batteries-included, web framework written in Python and Javascript. It is the framework that powers ERPNext. It is pretty generic and can be used to build database-driven apps.

Frappe framework is more like no/less code, configuration oriented framework. It is a Meta-data driven web framework written in Python and Javascript with MariaDB as its database.

Key features of Frappe

->MVC framework
->ORM support
->Auto generated UI based on Meta-data
->Provides users, user roles and permissions
->Comes with the scheduler (python RQ) for background jobs
->Real-time notifications and web sockets
->Templating based on Jinja
->Multi-language support comes out of the box.
->Re-usable apps
->Rest API
->Batteries included (email, OAUTH support, reports, payment gateway, chat)

When to use Frappe?

->To create ERP systems because it is not advised to use them outside of the ERP.
->Building the administration and business applications for small/medium-sized products.
->Internal tools and portals used for reports

Frappe Architecture:


When examining Frappe, the internal model-view creation and database declaration processes are the most important things to understand. It makes use of a meta-data-based declaration, which is simply a JSON file, to generate the database's tables and fields while providing a rich user interface with connections to the respective database fields.

Frappe Stack:

-> Programming Languages: Python and Javascript
-> Database: MariaDB and Postgres(no support for ERPnext)
-> Webserver: Werkzeug
-> Templating: Jinja
-> Job Queues: Python RQ(Scheduler)
-> CSS Framework: Bootstrap 3
-> Caching: Redis(In-memory)
-> Realtime: NodeJS + Socketio.js
-> Javascript Packaging: Rollup
-> Webserver: gunicorn + NGINX (Production)
-> Process Manager (Production): supervisord
-> Process Manager (Develop): Honcho
-> Command Line: Bench
-> Wkhtmltopdf : Command line tool to process HTML in PDF (report generation)

Key-terms:

Bench: Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications for development and production. A Command Line Interface(CLI) tool called Bench is used to manage Frappe Deployments. It offers a simple interface that makes it simple to set up and administer several sites and apps built on the Frappe Framework. The CLI tool and the directory are both referred to as "bench" in this context.

Desk: The admin interface in Frappe is called Desk which is generated using the meta-data(JSON).DocTypes and automatically builds list views, form views, report views, etc for your DocTypes and allows the option to set permissions for users to view/modify it.

DocType: DocType is responsible for models and views in Frappe, which holds the reason to be called as meta-based. It stores all the fields and its types of databases in JSON data. In short, it describes models and views.

Supports many-to-one relationship to the fields in the form of child DocType to a field.

Apps: It is a python package and should be under the directory apps in the frappe-bench directory. Each app should have an entry in apps.txt file just like in Django settinngs.py to be considered.

Directory Structure(Apps):


-> library_management: This directory will contain all the source code for your app
-> public: Store static files that will be served from Nginx in production
-> templates: Jinja templates used to render web views
-> www: Web pages that are served based on their directory path
-> library_management: Default Module bootstrapped with app
-> modules.txt: List of modules defined in the app
-> patches.txt: Patch entries for database migrations
-> hooks.py: Hooks used to extend or intercept standard functionality provided by the framework
-> requirements.txt: List of Python packages that will be installed when you install this app

Site: Each tenant on the Frappe platform is referred to as a site. Sites each have their own database. When using the bench command, the sites directory is taken into consideration as the current working directory.

Directory Structure(Site):


The private folder will include any database backups and personal files. User-uploaded private files require authentication in order to be accessed.
Unauthenticated access to the files in the public folder will be possible. Images from websites may be included here that are open to the public.

Links: The fields between two tables can be mapped with each other through Links and we need to specify the target fields from the parent table. This acts more of a foreign key reference.

How is Frappe different from Erpnext?

  • Frappe is the framework using which Erpnext is built. You can think of Frappe as a framework and Erpnext is an application built using Frappe.

  • You could build another application called Erpnext-advanced using Frappe.

  • Erpnext is a set of modules. Different modules in erpnext are stock, crm, restaurant, healthcare, education and several others.

  • You could quickly build another application called Erpnext-advanced using Frappe. This app could have modules library, grocery, bag etc.

ErpNext

ERPNext is a free and open-source integrated Enterprise Resource Planning (ERP) software developed by Frappe Technologies Pvt. Ltd. and is built on MariaDB database system using Frappe, a Python based server-side framework.

DOCTYPE

Before we can create DocTypes, we need to enable developer mode. This will enable boilerplate creation when we create doctypes and we can track them into version control with our app.
Go to your terminal and from the frappe-bench directory, run the following command:

$ bench --site library.test set-config --global developer_mode 1

A DocType is the core building block of any application based on the Frappe Framework. It describes the Model and the View of your data. It contains what fields are stored for your data, and how they behave with respect to each other. It contains information about how your data is named. It also enables rich Object Relational Mapper (ORM) pattern which we will discuss later in this guide. When you create a DocType, a JSON object is created which in turn creates a database table.


Workflows

With workflows you can rewrite how a particular process/workflow is approved in ERPNext.

You can set multiple levels of approval for an ERPNext Workflow. To allow multiple people to submit multiple requests, for approvals by multiple users, ERPNext requires you to fill the Workflow conditions. ERPNext tracks the multiple permissions before submission.

Consider a scenario, where multiple levels of approval are required for a quotation. A sales person (user with 'Sales User' role) will create a quotation. Then it is either approved or rejected by a sales lead (user with 'Sales Manager' role). If approved by sales lead, it is further approved or rejected by regional manager (user with 'Regional Manager' role).

To make a Workflow and transition rules go to:

Home > Settings > Workflow

Once a Workflow is created, you can take actions on it via Workflow Actions.
Prerequisites

Before creating a Workflow, it is advised to create these first:

  • Workflow Actions

  • Workflow States like Approved, Canceled, etc.

How to Create a Workflow

  • Go to the Workflow list, click on New.

  • Enter a name for the Workflow and select the DocType on which to be applied.

  • Enter the different states of the Workflow. Enter Doc Status for them, select which field to update from the Update Field column, enter what the value will be updated to under Update Value.

  • The Workflow States can have different colors according to the state. Eg: Green for success. Document statuses: Saved = 0, Submitted = 1, Cancelled = 2.


  • Enter the Transition Rules.



On this page